package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysCarResults;
import com.ruoyi.system.service.ISysCarResultsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检测结果Controller
 * 
 * @author ruoyi
 * @date 2022-05-11
 */
@RestController
@RequestMapping("/system/results")
public class SysCarResultsController extends BaseController
{
    @Autowired
    private ISysCarResultsService sysCarResultsService;

    /**
     * 查询检测结果列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysCarResults sysCarResults)
    {
        startPage();
        List<SysCarResults> list = sysCarResultsService.selectSysCarResultsList(sysCarResults);
        return getDataTable(list);
    }

    /**
     * 导出检测结果列表
     */
    @Log(title = "检测结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCarResults sysCarResults)
    {
        List<SysCarResults> list = sysCarResultsService.selectSysCarResultsList(sysCarResults);
        ExcelUtil<SysCarResults> util = new ExcelUtil<SysCarResults>(SysCarResults.class);
        util.exportExcel(response, list, "检测结果数据");
    }

    /**
     * 获取检测结果详细信息
     */
    @GetMapping(value = "/{resId}")
    public AjaxResult getInfo(@PathVariable("resId") Long resId)
    {
        return AjaxResult.success(sysCarResultsService.selectSysCarResultsByResId(resId));
    }

    /**
     * 新增检测结果
     */
    @Log(title = "检测结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysCarResults sysCarResults)
    {
        return toAjax(sysCarResultsService.insertSysCarResults(sysCarResults));
    }

    /**
     * 修改检测结果
     */
    @Log(title = "检测结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCarResults sysCarResults)
    {
        return toAjax(sysCarResultsService.updateSysCarResults(sysCarResults));
    }

    /**
     * 删除检测结果
     */
    @Log(title = "检测结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{resIds}")
    public AjaxResult remove(@PathVariable Long[] resIds)
    {
        return toAjax(sysCarResultsService.deleteSysCarResultsByResIds(resIds));
    }
}
